<template>
	<view class="go-1">
		<image class="im-1" src="../../static/images/lrx/loading.png" mode=""></image>
		<view class="wz-2">
			{{time}}s后进入
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				time: 1
			}
		},
		onLoad() {
			// 发请求去获取路径
			uni.request({
				url: 'http://pub.woniulab.com:8081/pub/site/xiancar',
				success: (res) => {
					console.log(res.data)
					let serveURL = res.data.data.protocol + "://" + res.data.data.baseUrl + ":" + res.data.data
						.port;
					uni.setStorageSync('serveURL', serveURL);
					console.log("保存的服务器地址:", serveURL);
					this.timd();
				}
			});
		},
		methods: {
			timd() {
				console.log("定时器")
				var tz = setInterval(() => {
					if (this.time > 0) {
						this.time--
					} else if (this.time == 0) {
						clearInterval(tz)
						uni.switchTab({
							url: '/pages/home/home'
						})
					}
				}, 1000)
			},
		}
	}
</script>

<style scoped lang="scss">
	.go-1 {
		position: relative;
		width: 750rpx;
		height: 100vh;

		.im-1 {
			position: absolute;
			width: 100%;
			height: 100%;
		}

		.wz-2 {
			position: absolute;
			top: 50%;
			left: 45%;
			color: #007AFF;
			font-size: 30rpx;
			font-weight: 700;
			width: 40%;
			height: 100%;
			z-index: 999;
		}

	}
</style>
